﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Styx.Helpers;
using Styx.Plugins.PluginClass;
using Styx.WoWInternals;
using System.Data.Odbc;
using System.Drawing;
using Styx;

namespace Answer
{
    class AutoAnswer : HBPlugin
    {
        public bool IsInitialized = false;
        private Core cr;

       public override string Author
        {
            get { return "Codebase"; }
        }

        public override string Name
        {
            get { return "AutoAnswer"; }
        }

        public override void Pulse()
        {
        
        }

        public override Version Version { 
            get { return new Version(0, 3, 2); } 
        }

       
        public override void Initialize()
        {
            if (IsInitialized) return;

            cr = new Core();
            cr.Load();

            Logging.Write(Color.Green, "[AutoAnswer] - Add events");
            WoWChat.Whisper += new WoWChat.ChatMessageHandlerEx<WoWChat.ChatWhisperEventArgs>(WoWChat_Whisper);
          
            
            Logging.Write(Color.Green, "[AutoAnswer] - Successfully loaded");

            IsInitialized = true;

        }

        public override void Dispose()
        {
            IsInitialized = false;
            cr.Clear();
            Logging.Write(Color.Green, "[AutoAnswer] - Cleared");
        }

       private void WoWChat_Whisper(WoWChat.ChatWhisperEventArgs e)
        {
            if (e.Author != StyxWoW.Me.Name)
            {
                Logging.Write(Color.Purple, "[AutoAnswer] - New whisper find answer");
                cr.GetAnswer(e.Message, e.Author);
            }

        }
        
      
    }
}
